﻿#pragma once

#include <vector>
#include <string>
#include "nlohmann/json.hpp"

/// <summary>
/// 矩形框
/// </summary>
class Rectangle
{
private:
	/// <summary>
	/// 左上角点的坐标
	/// </summary>
	int x, y;
	/// <summary>
	/// 宽度
	/// </summary>
	int width;
	/// <summary>
	/// 高度
	/// </summary>
	int height;

public:
	Rectangle() = delete;
	/// <summary>
	/// 矩形框
	/// </summary>
	/// <param name="lt">左上顶点坐标</param>
	/// <param name="rb">右下顶点坐标</param>
	Rectangle(int x, int y, int w, int h);
	NLOHMANN_DEFINE_TYPE_INTRUSIVE(Rectangle, x, y, width, height)
};

/// <summary>
/// 识别结果
/// </summary>
class Recognition
{
private:
	/// <summary>
	/// 矩形框
	/// </summary>
	Rectangle rect;
	/// <summary>
	/// 识别的分类标签
	/// </summary>
	std::string tag;
	/// <summary>
	/// 置信度
	/// </summary>
	double probability =-1;
public:
	Recognition() = delete;
	/// <summary>
	/// 使用矩形框、分类名称、置信度来构造一个识别结果对象
	/// </summary>
	/// <param name="r">矩形框对象</param>
	/// <param name="t">识别结果名称</param>
	/// <param name="o">置信度</param>
	Recognition(Rectangle r, std::string t, double o);
	NLOHMANN_DEFINE_TYPE_INTRUSIVE(Recognition, rect, tag, probability)
};

/// <summary>
/// 识别记录
/// </summary>
class Record
{
private:
	/// <summary>
	/// 识别到的物体集合
	/// </summary>
	std::vector<nlohmann::json> reco_list;
	std::string filename;
public:
	Record() = delete;
	/// <summary>
	/// 识别结果关联的文件名
	/// </summary>
	/// <param name="f"></param>
	Record(std::string f);
	/// <summary>
	/// 构造识别结果记录
	/// </summary>
	/// <param name="r">识别结果列表</param>
	Record(std::vector<nlohmann::json> r);
	/// <summary>
	/// 增加一个识别结果到识别结果记录中
	/// </summary>
	/// <param name="r">识别结果对象</param>
	void addRecognition(Recognition r);
	NLOHMANN_DEFINE_TYPE_INTRUSIVE(Record, reco_list)
};

